home *** CD-ROM | disk | FTP | other *** search
/ Aminet 3 / Aminet 3 - July 1994.iso / Aminet / disk / misc / dmafix.lzh / DMAfix.doc next >
Encoding:
Text File  |  1991-12-16  |  13.7 KB  |  270 lines

  1.                DMAfix v1.0 Copyright 1991 Barry McConnell
  2.  
  3.  
  4. This program is for anyone with an accelerator board which doesn't allow  DMA
  5. into  its  32-bit  memory,  eg.  the  CSA  Mega-Midget  Racer,  or  the   SSL
  6. A5000/B5000. It patches several DOS functions to make transfers to/from  your
  7. hard drive much faster. It should work  on  any  Amiga  (A500/A1000/A2000  (I
  8. presume no A3000 owner will ever need it...)), any OS (1.2/1.3/2.x), and  any
  9. accelerator board. It was written entirely in 68000 assembly language.
  10.  
  11.  
  12. Distribution:
  13. ~~~~~~~~~~~~~
  14.  
  15. This program is Shareware. If you like it (ie.  you're  getting  all  excited
  16. about seeing your hard drive operating normally again...), please  feel  free
  17. to send me a contribution. Since this program will greatly enhance the  power
  18. of something which you probably paid a great deal of money for (68030  boards
  19. with 32-bit RAM are *not* cheap!), I am  sure  you  will  find  it  extremely
  20. useful to have around. The sum of 10 UK/Irish pounds (or  the  equivalent  in
  21. any other currency) sounds reasonable to me; of course you can send  more  or
  22. less as you see fit. I will of course  reply  to  everyone  who  sends  me  a
  23. contribution, and let them know whenever I release an update. If you have  an
  24. e-mail address,  I  can  automatically  mail  you  the  latest  version  when
  25. available.
  26.  
  27. This program may be freely distributed as long  as  there  is  _no_  fee  for
  28. doing so, and that this doc file  remains  with  it,  and  both  it  and  the
  29. program remain unmodified. This means you may give (not  sell!)  it  to  your
  30. friends, upload it to bulletin boards and FTP sites, but you may not  include
  31. it in any PD library or distribute it as part of  a  commercial  package  (if
  32. you are marketing an accelerator board, you  must  get  in  contact  with  me
  33. first if you want to include this program with  it).  The  one  exception  to
  34. this is that Fred Fish is given  permission  to  include  it  on  his  freely
  35. distributable disk collection (but please e-mail me if you do this Fred!).
  36.  
  37.  
  38. Disclaimer:
  39. ~~~~~~~~~~~
  40.  
  41. It works fine on *my* Amiga (I have the SSL A5000 68020 board, an  A590  with
  42. a 52Mb Quantum, 1Mb of chip, 1Mb of 16-bit RAM, and 3Mb  of  32-bit  RAM).  I
  43. have left it running permanently  on  my  system  and  it  has  never  either
  44. crashed or destroyed any data on me. If it doesn't work for *you*, or  causes
  45. you to lose valuable data, then don't jump on me: just let me know  what  the
  46. problem is and I'll do my best to release a new version which cures it!
  47.  
  48. Be aware that this program modifies three very important  system  calls,  and
  49. that it has the potential to cause  havoc  with  your  hard  drive.  However,
  50. there is no "hacking" involved;  it  does  everything  in  a  system-friendly
  51. manner. As I said, I have had no nasty experiences with it.
  52.  
  53. Of course, you will have done a complete backup before  using  this  program,
  54. and will test  it  properly  before  relying  completely  on  it.  If  you're
  55. _really_ paranoid, you can lock each of your  HD  partitions  before  running
  56. it, eg.
  57.  
  58. lock dh0: on
  59. lock dh1: on
  60.  
  61. I don't guarantee that every program ever written for  the  Amiga  will  work
  62. with DMAfix; everything should, but there is a chance  that  something  might
  63. not. All I can say is, it works with all my software, and I even ran my  disk
  64. optimiser with DMAfix, and everything seems to be still intact... :-)
  65.  
  66. (Phew, disclaimer over; hope it didn't put you off using the program!)
  67.  
  68.  
  69. Quick Installation:
  70. ~~~~~~~~~~~~~~~~~~~
  71.  
  72. If you don't want to have to read the rest  of  this  doc  file  (although  I
  73. encourage you to do so), or just want to quickly see if  it  works,  then  go
  74. into a Shell/CLI and type:
  75.  
  76. makedir ram:dma
  77. assign dma: ram:dma
  78. run DMAfix
  79.  
  80. Now try booting an application, or copying a large file to the RAM  disk,  or
  81. running something like DiskSpeed, and notice the difference!!
  82.  
  83. To quit, type break <task>, where <task> is the process ID  of  DMAfix  (type
  84. status to find this out). Note that this 'quick' method of installation  will
  85. only work if the  offending  32-bit  memory  is  outside  the  16Mb  (24-bit)
  86. address space; if you have non DMA-able memory inside the 16Mb  space  (quite
  87. unusual, I think), then you  will  need  to  read  the  next  section  before
  88. running the program...
  89.  
  90.  
  91. How to Install:
  92. ~~~~~~~~~~~~~~~
  93.  
  94. Boot HD-Toolbox (or the equivalent for your system)  and  check  the  Address
  95. Mask for your controller  (in  HD-Toolbox,  go  to  Partition  Drive/Advanced
  96. Options/Change File System, and note down the Mask  parameter).  This  number
  97. tells the FileSystem where it can DMA to. Pad it out with  leading  zeros  if
  98. necessary to form 8 hex digits (eg. mine is fffffe (ignoring the  0x  at  the
  99. start), so it becomes 00fffffe), and use that as the one and  only  parameter
  100. which DMAfix takes (eg. run DMAfix 00fffffe). This  number  is  actually  the
  101. default if you don't enter any parameter, since the problem generally  occurs
  102. with memory outside the 16Mb address space.
  103.  
  104. I recommend running this program from your Startup-Sequence; as near  to  the
  105. beginning as possible.
  106.  
  107.  
  108. The Problem:
  109. ~~~~~~~~~~~~
  110.  
  111. This section is for those of you who  don't  actually  know  why  their  hard
  112. drive  performance  suffers  so  much  with  non-DMA  32-bit   memory.   This
  113. information was posted by Mike Sinz of  Commodore  (hi  Mike!)  on  Usenet  a
  114. while back; I'll summarize it.
  115.  
  116. When the  FileSystem  notices  that  an  application  has  requested  a  data
  117. transfer from your hard drive into memory it cannot DMA into  (generally  32-
  118. bit memory outside of the 16Mb address space), it has  to  do  some  "magic".
  119. What it does is set up a 512-byte buffer down in low memory (16-bit fast  RAM
  120. or chip RAM) where DMA does work, and repeatedly DMAs into that  in  512-byte
  121. chunks and CPU-copies them up to the buffer in high  memory.  There  are  two
  122. speed hits here. The obvious one is the overhead in having to copy  all  that
  123. data around (although in practice, an  '020/'030  is  pretty  fast  at  doing
  124. this, even when 16-bit RAM is involved). The  other  one  (which  causes  the
  125. most slowdown) is reading only half a K chunks  off  your  hard  drive  at  a
  126. time, as it is a LOT faster to read, say, 128K at once  than  256  blocks  of
  127. 512 bytes.
  128.  
  129.  
  130. The Solution:
  131. ~~~~~~~~~~~~~
  132.  
  133. Simple, increase the buffer size down in low memory! Unfortunately, the  size
  134. of this buffer is hardcoded into both the 1.3 and 2.0 ROM  (in  actual  fact,
  135. it's based around the size of one sector, so it's  not  simply  a  matter  of
  136. changing a 512 to a 65536...). I didn't  feel  like  disassembling  ROMs,  so
  137. another method had to be used.
  138.  
  139. What my program does is  patch  three  DOS  functions:  Read(),  Write()  and
  140. LoadSeg(). For Read(), it basically asks the question "Is the user trying  to
  141. DMA more than 512 bytes into 32-bit memory?" and  if  the  answer  is  "yes",
  142. then it sets up its own (big!) buffer in low (chip) memory, and goes  into  a
  143. loop calling the original Read() to get data into that buffer, and then  CPU-
  144. copying it up to the original buffer. Ideally, it only has to do one  Read(),
  145. as it first tries allocating enough memory for the whole amount  of  data  to
  146. be read, then tries 256K, then 64K, then flashes the  screen,  gives  up  and
  147. jumps back into the original function... The procedure for Write() is  pretty
  148. similar: it does the same in  reverse,  ie.  CPU-copies  the  data  into  the
  149. temporary buffer before DMA-ing out to your hard drive.
  150.  
  151. Unfortunately, LoadSeg() doesn't call  Read()  via  the  normal  vectors  (it
  152. calls Read() directly; naughty naughty!),  so  it  will  still  be  painfully
  153. slow. I had to think of another way to get around this. The solution  I  came
  154. up with was to copy the file into the RAM disk  (using  a  256K  (or  64K  if
  155. memory is low) DMA-able buffer so it's fast!)  and  then  LoadSeg()  it  from
  156. there. It works, and isn't as slow as you'd think it would be! Note  that  it
  157. uses the assignment dma: when copying the file, so this is why  you  have  to
  158. assign this to  somewhere  (unused)  in  the  RAM  disk  before  running  the
  159. program.
  160.  
  161.  
  162. Speed:
  163. ~~~~~~
  164.  
  165. This program will make your hard  drive  perform  so  close  to  how  it  was
  166. originally  with  the  68000  that  you  should  not  be  able  to  tell  the
  167. difference. Using DiskSpeed 4, I have seen that speeds are to within  10%  of
  168. what they were originally. Booting  applications  gives  similar  performance
  169. too, even though they have to  be  copied  to  the  RAM  disk  first.  As  an
  170. example, booting DPaint without DMAfix takes about 10 seconds;  with  DMAfix,
  171. it is a little over 2 seconds (slightly slower  than  in  68000  mode).  With
  172. DiskSpeed 4, I get 573K/sec in 68000 mode, 36K/sec (!) in 68020 mode  without
  173. DMAfix, and 527K/sec with DMAfix. When DMA-ing into chip RAM in  68020  mode,
  174. I get 706K/sec, which is a good indication of how fast you would  be  without
  175. the DMA problem, and also shows that there isn't  too  high  an  overhead  in
  176. copying all the data around (around a 25% slowdown).
  177.  
  178.  
  179. Problems/Features:
  180. ~~~~~~~~~~~~~~~~~~
  181.  
  182. This program is very memory-intensive. If you request a  1Mb  file  transfer,
  183. it will first try AllocMem()ing 1024K, and if it fails it will try 256K,  and
  184. finally 64K before giving up. (The screen will flash  if  this  happens.)  Of
  185. course, this will have to be chip RAM (I'm working on a  routine  which  will
  186. allocate 16-bit fast RAM if available): it might be a good idea to make  sure
  187. you have plenty of this free. With only 512K of it, you  might  be  a  little
  188. pushed at times (although if you are getting to the point at which  there  is
  189. less than 64K available, a slow hard drive is going to be the least  of  your
  190. worries...), but I find with 1Mb of chip,  I  rarely  run  out.  Maybe  in  a
  191. future version I will allow even smaller buffers (even an 8K buffer  will  be
  192. reasonably fast), or a fixed (large) buffer defined at startup time.
  193.  
  194. At this point you may be muttering things like "memory  fragmentation";  well
  195. it shouldn't affect fragmentation too  much  as  it  deallocates  the  memory
  196. pretty quickly  (hopefully  no  other  task  has  asked  for  memory  in  the
  197. meantime!).
  198.  
  199. The worst-case scenario comes when you try to boot  something  like  ProPage.
  200. It will try to allocate 450K so it can copy the  application,  and  use  this
  201. buffer to get it into the RAM disk (another 450K of 32-bit  RAM  this  time).
  202. The original 450K buffer will then be freed, and ProPage will be  booted  off
  203. the RAM disk (immediately taking up  yet  another  great  chunk  of  memory).
  204. Unfortunately when it then tries to delete ProPage from the RAM disk it  will
  205. fail, as ProPage is one of the (few?) applications which uses overlays.  This
  206. means that the file will still be open, and it cannot delete it until  either
  207. ProPage closes it, or you quit ProPage. In actual fact, it  tries  to  delete
  208. it every time you boot another application, and  should  eventually  succeed.
  209. ProPage and MRBackup are the only programs which  I  have  seen  having  this
  210. problem. Of course, if you're into DTP  then  you  probably  have  a  lot  of
  211. memory to play around with, so you won't mind. :-)  If the  file  refuses  to
  212. go away, you can of course delete it manually (as long as  it  is  not  still
  213. open; you'll get  an  error  message  if  it  is...).  If  you  find  that  a
  214. particular application always leaves its file in dma: even after quitting  it
  215. and booting  something  else,  then  please  let  me  know.  (This  shouldn't
  216. happen!)
  217.  
  218. Anyway, the point I'm trying to get across is that you will  need  plenty  of
  219. memory to make full use of DMAfix. It will work no  matter  how  much  memory
  220. you have free, but the more memory it can grab, the faster it will be...
  221.  
  222. The patches would normally affect _all_ reads and  writes;  even  when  using
  223. the RAM disk or the console! Hence, I have put in a  few  additional  checks.
  224. If the filehandle passed to Read() is the same as the current Input()  stream
  225. (or the filehandle passed to Write() is  the  same  as  Output()),  then  the
  226. original function is used instead. If the first three letters of  the  device
  227. in question are "RAM" (case insensitive, so it could also be  Ram),  it  uses
  228. the original function too. So make sure your RAM disk(s) volume  names  begin
  229. with "RAM", and your hard disk partitions don't! :-)  I know  it  will  still
  230. intercept calls to the floppy drive - sorry! However  floppies  are  so  slow
  231. anyway that you won't notice the difference. ;-)
  232.  
  233. The program really likes 2.0! While it works under 1.3, I have  noticed  that
  234. some things (eg. the Copy command) don't appear to take full advantage of  it
  235. and are still very slow. Also I don't know how to easily find out the  volume
  236. name of the filehandle under 1.3 (there's a  function  called  NameFromFH  in
  237. 2.0), so you will find your RAM disk a bit slower (for me, it goes down  from
  238. 5Mb/sec to 1Mb/sec; so it's still very fast...).
  239.  
  240.  
  241. Credits:
  242. ~~~~~~~~
  243.  
  244. Well, the program was obviously written by me, but a special  thanks  has  to
  245. go to Eddy Carroll who helped me out whenever I got stuck (frequently!),  and
  246. who also gave me some ideas on how to do it in the first place.  Since  I  am
  247. relatively new on the Amiga scene, and this is only my  second  project  (the
  248. first one hasn't been finished yet; I put it on 'hold' to do this...), I  had
  249. a LOT of questions for him about the intricacies of the Amiga system.
  250.  
  251.  
  252. Contacting me:
  253. ~~~~~~~~~~~~~~
  254.  
  255. If you have any bug reports, suggestions, comments,  questions  or  money,  I
  256. can be reached at:
  257.  
  258. Snail mail:  Barry McConnell,
  259.              "Piper's Hollow",
  260.              Hillcrest Road,
  261.              Dublin 18,
  262.              Ireland.
  263.  
  264. Internet:    bmccnnll@unix1.tcd.ie  [that's double-el and unix-one!]
  265.              bmccnnll@vax1.tcd.ie  [will be forwarded to my UNIX account]
  266.  
  267. I don't envisage any of these addresses changing before the end of 1995!!
  268.  
  269. No, don't tell me this doc file is longer than the program itself... :-\
  270.